

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
// layout
import { LayoutProComponent } from '@brand';
import { EATokenGuard } from '@core';
import { environment } from '@env/environment';

import { AuthGuard } from '../core/guards/auth.guard';

// dashboard pages
import { DashboardComponent } from './dashboard/dashboard.component';
import { OrderAgreementComponent } from './passport/components/order-agreement/order-agreement.component';

const routes: Routes = [
  {
    path: '',
    component: LayoutProComponent,
    canActivate: [AuthGuard, EATokenGuard],
    canActivateChild: [AuthGuard, EATokenGuard],
    children: [
      { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
      { path: 'dashboard', component: DashboardComponent, data: { title: '首页' } },
      {
        path: 'account',
        loadChildren: () => import('./account/account.module').then(m => m.AccountModule)
      },
      {
        path: 'usercenter',
        loadChildren: () => import('./usercenter/usercenter.module').then(m => m.UsercenterModule)
      },
      { path: 'system', loadChildren: () => import('./sys-setting/sys-setting.module').then(m => m.SysSettingModule) },
      { path: 'logs', loadChildren: () => import('./logs/logs.module').then(m => m.LogsModule) },
      { path: 'ticket', loadChildren: () => import('./ticket-management/ticket-management.module').then(m => m.TicketManagementModule) },
      { path: 'vehicle', loadChildren: () => import('./vehicle/vehicle.module').then(m => m.VehicleModule) },
      {
        path: 'supply-management',
        loadChildren: () => import('./supply-management/supply-management.module').then(m => m.SupplyManagementModule)
      },
      {
        path: 'insurance-management',
        loadChildren: () => import('./insurance-management/insurance-management.module').then(m => m.InsuranceManagementModule)
      },
      {
        path: 'order-management',
        loadChildren: () => import('./order-management/order-management.module').then(m => m.OrderManagementModule)
      },
      {
        path: 'waybill-management',
        loadChildren: () => import('./waybill-management/waybill-management.module').then(m => m.WaybillManagementModule)
      },
      {
        path: 'financial-management',
        loadChildren: () => import('./financial-management/financial-management.module').then(m => m.FinancialManagementModule)
      },
      {
        path: 'contract-management',
        loadChildren: () => import('./contract-management/contract-management.module').then(m => m.ContractManagementManagementModule)
      },
      { path: 'menu-management', loadChildren: () => import('./menu-manager/menu-manager.module').then(m => m.MenuManagerModule) },
      { path: 'partner', loadChildren: () => import('./partner/partner.module').
      then(m => m.PartnerModule) },
      { path: 'regulatory-data', loadChildren: () => import('./regulatory-data/regulatory-data.module').then(m => m.RegulatoryDataModule) },
      {
        path: 'download',
        loadChildren: () => import('./download/download.module').then(m => m.DownloadModule)
      },
      { path: 'datatable', loadChildren: () => import('./datatable/datatable.module').then(m => m.DatatableModule) },
      { path: 'tax', loadChildren: () => import('./tax-management/taxmanagement.module').then(m => m.TaxManagementModule) },
      {
        path: 'interface-docking',
        loadChildren: () => import('./interface-docking/interface-docking.module').then(m => m.InterfaceDockingModule)
      }
    ]
  },
  // passport
  { path: '', loadChildren: () => import('./passport/passport.module').then(m => m.PassportModule) },
  { path: 'exception', loadChildren: () => import('./exception/exception.module').then(m => m.ExceptionModule) },
  // 单页不包裹Layout
  { path: '**', redirectTo: 'exception/404' }
];

@NgModule({
  imports: [
    RouterModule.forRoot(routes, {
      useHash: environment.useHash,
      // NOTICE: If you use `reuse-tab` component and turn on keepingScroll you can set to `disabled`
      // Pls refer to https://ng-alain.com/components/reuse-tab
      scrollPositionRestoration: 'top'
    })
  ],
  exports: [RouterModule]
})
export class RouteRoutingModule {}
